// 登录脚本
layui.use(['request', 'redirect', 'form', 'layer'], function () {
    var form = layui.form
        , user = layui.user
        , layer = layui.layer
        , request = layui.request;

    form.on('submit(login)', function(data){
        var field = data.field;
        var requestData = { username: field.username, password: field.password, code: "000", token: "000" }
        request.send('/login/submit', 'POST', requestData, true, function (code, message, res) {
            if (code === 200) {
                user.login(res.token, res.user);
                layui.redirect.auto();
            } else {
                layer.msg(message);
            }
        })
        return false;
    });
})